<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="cn.edu.scau.cmi.tangqingning.model.*,java.net.*"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<head>

<%
	if (request.getAttribute("user") == null) {//获得请求参数
		String username = null;
		String password = null;

		/* Cookie把在网页上所输入的文字记录下来,以便使Web服务器去查找是否存在它上次留下的Cookie资料 */
		Cookie[] cookies = request.getCookies(); //读出用户硬盘上的Cookie，并将所有的Cookie放到一个cookie对象数组里面
		for (int i = 0; cookies != null && i < cookies.length; i++) {
			if (cookies[i].getName().equals("user")) {
				username = URLDecoder.decode(cookies[i].getValue().split("-")[0], "UTF-8");
				password = URLDecoder.decode(cookies[i].getValue().split("-")[1], "UTF-8");
			}

			if (username == null) {
				username = "";
			}
			if (password == null) {
				password = "";
			}
			/* 找到Cookie里面存有的账号密码，则保存  */
			pageContext.setAttribute("username", username);
			pageContext.setAttribute("password", password);
		}
	}
%>
<title>同行互评系统</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes">
<link
	href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/bootstrap/css/bootstrap-responsive.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/mycss/button.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/mycss/login.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/mycss/select.css"
	rel="stylesheet">
<%--        <script type="text/javascript" src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.js"></script> --%>
<style type="text/css">
* {
	box-sizing: border-box;
}

body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	font: 16px/20px microsft yahei;
}

</style>
</head>
<body>
	<div class="wrap">
		<div class="container">
			<h1>系统登录</h1>
			<form action="login" method="post"
				onSubmit="return validatepassword()">
				<table align="center">
					<tr>
						<td><font color="red">${error}</font></td>
					</tr>
					<tr>
						<td><input type="text" name="username" placeholder="用户名" maxlength="12"
							id="username" onkeyup="this.value=this.value.replace(/\s+/g,'')"
							value="${username}"></td>
					</tr>
					<tr>
						<td><input type="password" name="password" placeholder="密码" maxlength="12"
							id="password" onkeyup="this.value=this.value.replace(/\s+/g,'')"
							value="${password }"></td>
					</tr>
					<tr>
						<td style="text-align:left"><input type="checkbox"
							id="remember" name="remember" value="remember-me"> <font color="white"><small>记住密码</small></font> 
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<label for="userlogin"
							class="radio"> <span class="radio-bg"></span> <input
								type="radio" name="loginId" id="userlogin" value="userLogin" 
								>管理员 <span class="radio-on"></span>
						</label> <label for="stulogin" class="radio"> <span
								class="radio-bg"></span> <input type="radio" name="loginId"checked="true"
								id="stulogin" value="studentLogin">学生 <span
								class="radio-on"></span>
						</label></td>
					</tr>
					<tr>
						<td>
							<input type="submit" value="登录"/>

						</td>
					</tr>
					<tr>
						
					</tr>
					<tr>
						<td><label class="labelError" id="passwordError"></label></td>
					</tr>
				</table>
			</form>
		</div>
		<ul>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
		</ul>
	</div>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jQuery.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/login.js"></script>
</body>
</html>
